﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.DataVisualization.Charting;
using System.Drawing;

public partial class Page_testChart : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        Series s = new Series();
        s.ChartType = SeriesChartType.Column;
        s.XValueType = ChartValueType.String;

        foreach (int i in new int[]{3,5,14,2})
        {
            DataPoint dp = new DataPoint();
            dp.Color = GetRandomColor(i);
            dp.YValues = new double[] { i };
            dp.LegendText = "123";
            dp.AxisLabel = "123";
            s.Points.Add(dp);
        }
        chart.Series.Add(s);
    }
    public Color GetRandomColor(int seed)
    {
        Random RandomNum_First = new Random(seed);
        Random RandomNum_Sencond = new Random(seed);

        int int_Red = RandomNum_First.Next(256);
        int int_Green = RandomNum_Sencond.Next(256);
        int int_Blue = (int_Red + int_Green > 400) ? 0 : 400 - int_Red - int_Green;
        int_Blue = (int_Blue > 255) ? 255 : int_Blue;

        return Color.FromArgb(int_Red, int_Green, int_Blue);
    }
}
